/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2024 All Rights Reserved.
 */
package com.alipay.demo.controller;

import com.alipay.api.response.AlipayOpenAppDeliveryInfoQueryResponse;
import com.alipay.demo.service.ItemDeliveryService;
import com.alipay.demo.vo.DeliveryTemplateQueryResponse;
import com.alipay.demo.vo.ItemDeliverySyncRequest;
import com.alipay.demo.vo.OpenResponse;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author jishupei.jsp
 * @version : ItemDeliveryController, v0.1 2024年05月17日 3:17 下午 jishupei.jsp Exp $
 */
@Api(tags = "普通商品履约模块")
@ApiSupport(order = 2)
@RestController
@RequestMapping(value = "/delivery")
public class ItemDeliveryController {

    @Autowired
    private ItemDeliveryService itemDeliveryService;

    /**
     * 普通商品履约模板查询
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "普通商品履约模板查询")
    @GetMapping(value = "/template/query")
    public OpenResponse<DeliveryTemplateQueryResponse> queryTemplate(
            @ApiParam(value = "履约类型，EXPRESS-电商卖货，PICKUP-到店自提，SAME_CITY-外卖到家", required = true) @RequestParam String deliveryType) {
        return itemDeliveryService.queryTemplate(deliveryType);
    }

    /**
     * 普通商品履约信息同步
     */
    @ApiOperation(value = "普通商品履约信息同步")
    @ApiOperationSupport(order = 2)
    @PostMapping(value = "/sync")
    public OpenResponse<String> sync(@RequestBody ItemDeliverySyncRequest request) {
        return itemDeliveryService.sync(request);
    }

    /**
     * 普通商品履约信息查询
     */
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "普通商品履约信息查询")
    @GetMapping(value = "/info/query")
    public OpenResponse<AlipayOpenAppDeliveryInfoQueryResponse> queryInfo(
            @ApiParam(value = "履约类型，EXPRESS-电商卖货，PICKUP-到店自提，SAME_CITY-外卖到家") @RequestParam(required = false) String deliveryType,
            @ApiParam(value = "履约信息ID列表") @RequestParam(required = false) List<String> deliveryIds) {
        return itemDeliveryService.queryInfo(deliveryType, deliveryIds);
    }
}
